package graphics;

import java.awt.Color;
import java.awt.Rectangle;
import java.awt.Shape;

import util.Point;
import java.awt.Polygon;
import java.awt.geom.Point2D;
import java.awt.geom.Rectangle2D;

import objects.NebulaConstants;

import ship.ShipConstants;

public class Drawing {

	public static void drawShip(MaxGraphics g, Point cords, double angle, double shields, double shieldCycle) {
		g.translate(cords.getX(), cords.getY());

		g.rotate(angle);

		g.setColor(Color.BLUE);
		for(Polygon p : ShipConstants.model) {
			g.fillPolygon(p);
		}

		drawShipShield(g, cords, shields, shieldCycle);

		g.rotate(-angle);
		g.translate(-cords.getX(), -cords.getY());
		g.setColor(Color.cyan);
		g.drawRect((int) cords.getX(), (int)  cords.getY(), 1, 1);

	}

	public static void drawPulse(MaxGraphics g, Point cords, double radius) {
		for(int i = 0; i < 7; i++) {
			g.setColor(new Color((float) 0.0, (float)0.0, Math.max(0, (float)(1-(i*.1)))));
			g.drawOval(cords.getX(), cords.getY(), radius-i, radius-i);
		}
	}

	public static void drawShipShield(MaxGraphics g, Point cords, double shields, double shieldCycle) {
		if(shields == 0) { 
			return;
		}
		for(int i = 0; i < 7; i++) {
			g.setColor(new Color((float) 0.0, (float)0.0, Math.max(0, (float)(shields-(i*.1)))));
			g.drawOval(0, 0, shieldCycle-i, shieldCycle-i);
		}
	}

	public static void drawAsteroid(MaxGraphics g, Point cords, Point rad) {
		g.setColor(Color.WHITE);
		g.drawOval((int) cords.getX(), (int) cords.getY(), rad.getX(), rad.getY());
	}

	public static void drawShot(MaxGraphics g, Point cords, Point last) {
		g.setColor(Color.red);
		g.drawLine(last.getX(), last.getY(), cords.getX(), cords.getY());
		g.drawRect((int) cords.getX(), (int) cords.getY(), 1, 1);	
	}

	public static void drawNebula(MaxGraphics mg, Shape[] s, int[] color) {
		
		for(Shape shape : s) {
			
		}
	}
}